<?php

class ImageInfo
{
    private $imagePath;

    public function __construct($imagePath)
    {
        $this->imagePath = $imagePath;
    }

    public function getInfo($key)
    {
        switch ($key) {
            case 'name':
                return pathinfo($this->imagePath, PATHINFO_FILENAME);
            case 'mime':
                return mime_content_type($this->imagePath);
            case 'path':
                return $this->imagePath;
            case 'ext':
                return pathinfo($this->imagePath, PATHINFO_EXTENSION);
            case 'size':
                return filesize($this->imagePath);
            case 'md5':
                return md5_file($this->imagePath);
            case 'sha1':
                return sha1_file($this->imagePath);
            case 'width':
                return getimagesize($this->imagePath)[0];
            case 'height':
                return getimagesize($this->imagePath)[1];
            default:
                return null;
        }
    } 
}

